package com.hdu.dwh.controller;


import com.hdu.dwh.dtos.SubjectTableDto;
import com.hdu.dwh.dtos.TablePageDto;
import com.hdu.dwh.service.ISubjectTableService;
import com.hdu.dwh.results.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Delete;
import org.springdoc.core.annotations.RouterOperation;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 主题数据表 前端控制器
 * </p>
 *
 * @author bobo
 * @since 2025-04-08
 */
@RestController
@RequestMapping("/subject/table")
@RequiredArgsConstructor
@Tag(name = "主题数据表")
@Deprecated
public class SubjectTableController {

    private final ISubjectTableService subjectTableService;


    @Operation(summary ="新增主题数据表")
    @PostMapping("/add")
    public ResponseResult add(@Valid @RequestBody SubjectTableDto subjectTableDto) {
        return subjectTableService.add(subjectTableDto);
    }

    @Operation(summary ="查询详细信息")
    @GetMapping("/{id}")
    public ResponseResult getDetilById(@PathVariable Long id) {
        return subjectTableService.getDetilById(id);
    }


    @Operation(summary ="查资产详情(分页)")
    @PostMapping("/page")
    public ResponseResult page(@Valid @RequestBody TablePageDto tablePageDto){
        return subjectTableService.detilPage(tablePageDto);
    }

    @Operation(summary ="查询所有数据表")
    @GetMapping("/table")
    public ResponseResult getTable(@RequestParam(required = false) Long databaseId, @RequestParam(required = false) String databaseName, @RequestParam(required = false) Integer hierarchy) {
        return subjectTableService.getTable(databaseId, databaseName, hierarchy);
    }

    @Operation(summary ="查询业务包")
    @GetMapping("/tree")
    public ResponseResult tree() {
        return subjectTableService.tree();
    }

    @Operation(summary ="删除主题表")
    @DeleteMapping("/{id}")
    public ResponseResult deleteById(@PathVariable Long id) {
        return subjectTableService.deleteById(id);
    }
}
